home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Plaid Pocket / Plaid / Source 4 Plaid Pocket < prev   
Encoding:
Text File  |  2000-06-23  |  2.1 KB  |  74 lines

  1. tell application "Finder"
  2.     set picFile to file "plaid.pict" of folder "Plaid" of startup disk as alias
  3. end tell
  4. tell application "Appearance"
  5.     activate
  6.     set picture file of monitor 1 to picFile
  7.     set picture positioning of monitor 1 to centered
  8.     quit
  9. end tell
  10. repeat
  11.     delay 15
  12.     tell application "Finder"
  13.         set theWidth to 128
  14.         set theHeight to 128
  15.         set theBounds to bounds of content space of desktop
  16.         set theRight to item 3 of theBounds
  17.         set theBottom to item 4 of theBounds
  18.         set myTop to (theBottom - theHeight) / 2
  19.         set myLeft to (theRight - theWidth) / 2
  20.         set myBottom to (theBottom + theHeight) / 2
  21.         set myRight to (theRight + theWidth) / 2
  22.         set myRect to {{myLeft, myTop}, {myRight, myBottom}}
  23.         set myFiles to every item in desktop
  24.         set myList to {}
  25.         repeat with myfile in myFiles
  26.             if my isInRect(position of myfile, myRect) then
  27.                 set myList to myList & myfile
  28.             end if
  29.         end repeat
  30.         if (count of items of myList) > 0 then
  31.             my Pocketize()
  32.             my toPocket(myList)
  33.         end if
  34.     end tell
  35. end repeat
  36. on isInRect(myPoint, myRect)
  37.     set x to item 1 of myPoint
  38.     set x1 to item 1 of item 1 of myRect
  39.     set x2 to item 1 of item 2 of myRect
  40.     set y to item 2 of myPoint
  41.     set y1 to item 2 of item 1 of myRect
  42.     set y2 to item 2 of item 2 of myRect
  43.     set isIn to ((x1 < x and x < x2) and (y1 < y and y < y2))
  44. end isInRect
  45.  
  46. on toPocket(theList)
  47.     tell application "Finder"
  48.         repeat with myItem in theList
  49.             move (myItem) to (folder "Shallow Pocket" of startup disk)
  50.         end repeat
  51.     end tell
  52. end toPocket
  53.  
  54. on Pocketize()
  55.     
  56.     tell application "Finder"
  57.         if not ((folder "Shallow Pocket" of startup disk) exists) then
  58.             make new folder in startup disk
  59.             set name of result to "Shallow Pocket"
  60.         end if
  61.         if not ((folder "Shallow Pocket:Pocket" of startup disk) exists) then
  62.             make new folder in folder "Shallow Pocket" of startup disk
  63.             set name of result to "Pocket"
  64.         end if
  65.         if not ((folder "Pocket" of desktop) exists) then
  66.             make new folder at desktop
  67.             set name of result to "Pocket"
  68.         end if
  69.         move every item in folder "Shallow Pocket" of startup disk to folder "Pocket" of desktop
  70.         move folder "Pocket" of desktop to folder "Shallow Pocket" of startup disk
  71.     end tell
  72. end Pocketize
  73.  
  74.